var requestCount=0;

function loadCQ(){
    var ids="";
    $("#productWrap").find(".w-goods-cache").each(function(index,element){
        var dataId=$(this).attr("data-id");
        ids=ids+dataId+"_";
    });
    $.ajax({
        url: "/db/cQ",
        type: "GET",
        data: {
            q: ids
        },
        dataType: "json",
        cache: false,
        success: function(data) {
            $("#productWrap").find(".w-goods-cache").each(function(index,element){
                var $this=$(this);
                var dataId=$this.attr("data-id");
                var dataSum=$this.attr("data-sum");
                var current=data.list[dataId];
                var progressData=((current*100)/dataSum).toFixed(2);
                $this.find(".bar").css("width",progressData+"%");
                $this.find(".cq").html(progressData+"%");
                $this.find(".w-goods-f").html("已购:"+current+"人次,剩余:"+(dataSum-current)+"人次");
            });
        },error:function(){
            if(requestCount<3) loadCQ();
        }
    });
    requestCount=requestCount+1;
}
function loadNL(){
    $.ajax({
        url: "/wo/unikey",
        type: "GET",
        dataType: "json",
        cache: false,
        success: function(data) {
            $.ajax({
                url: "/wo/nl",
                type: "GET",
                dataType: "json",
                data: {unikey: data.content},
                cache: false,
                success: function(data) {
                },error:function(){}
            });
        },error:function(data){}
    });
}
loadCQ();
loadNL();